package tdh.xt.entity;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import tdh.xt.entity.po.User;

import java.util.List;
import java.util.Map;

@Component
public class Translater {
    @Value("#{departService.departCodeAndName}")
    private Map<String, String> departCodeAndName;

    @Value("#{bzdmService.xbCodeAndName}")
    private Map<String, String> xbCodeAndName;


    public void translate(User user) {
        user.setYhbm(departCodeAndName.containsKey(user.getYhbm()) ? departCodeAndName.get(user.getYhbm()) : user.getYhbm());
        user.setYhxb(xbCodeAndName.containsKey(user.getYhxb()) ? xbCodeAndName.get(user.getYhxb()) : user.getYhxb());
    }

    public void translate(List<User> users) {
        for (User user : users) {
            translate(user);
        }
    }
}
